package com.gmall.gateway.filter;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

@Component
public class AuthFilter implements GlobalFilter, Ordered {
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {

        ServerHttpRequest request = exchange.getRequest();
        System.out.println("request Path" + request.getPath());
        ServerHttpResponse response = exchange.getResponse();


        return chain.filter(exchange);//放行
    }


    @Override
    public int getOrder() {//
        // 返回一个int值来确定过滤器的执行顺序
        // 返回一个负数表示该过滤器需要在其他过滤器之前执行
        return -100;
    }
}
